Return to doc.sitecore.com

Passing parameters to a custom .html editor
Prev Next

Author: Alexander Tsvirchkov
Posted: 8/31/2006 9:17:04 PM

The Question:
I used IFraime filed and use my custom page as editor e.g. http://domain/layouts/MyEditor.html. How can I know:

  1. Which item is selected in Content Editor?
  2. Which language is selected in Content Editor?
  3. Which version of an item is selected in Content Editor?

Sitecore version used: 5.2.0.10

The Answer:

When Sitecore executes a custom page the following parameters are passed:

http://localhost/layouts/Myeditor.html?id=%7bBF0BB4BC-10DE-4F02-9FA1-11EE18AC1404%7d&vs=1&la=da  

Use the following code for the MyEditor.html page to show all parameters: 

using Sitecore;
using Sitecore.Configuration;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.SecurityModel;
using Sitecore.Collections;
using Sitecore.Links;

 
 
      protected void Page_Load(object sender, EventArgs e)
      {
         Sitecore.Data.Database dbMaster = Sitecore.Configuration.Factory.GetDatabase("master");
 
         Sitecore.Data.Items.Item itm = dbMaster.Items[Request.QueryString.Get("id")];
         string language = Request.QueryString.Get("la");
         string version = Request.QueryString.Get("vs");
 
         if (itm != null)
         {
            Response.Write(
                  "ID is " + itm.ID.ToString()
               + "<br/> Language is :" + language
               + "<br/> Version is :" + version);
         }
 
      }

Prev Next